package com.jxm;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2022/5/9 21:45
 * @Version: 1.0
 */
public class MyFirstServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        String requestURI = req.getRequestURI();
        System.out.println("------------------------------"+requestURI);
//        PrintWriter writer = resp.getWriter();
//      writer.print(requestURI);

        ServletOutputStream out = resp.getOutputStream();
        String str = "Hell servlet" + "贾";
//        resp.getWriter().print(str);
        out.write(str.getBytes());
        out.close();



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }
}
